﻿<%@ Page Language="C#" MasterPageFile="~/Master.Master" AutoEventWireup="true" CodeBehind="RC_Command.aspx.cs" Inherits="KPIS.GERP.GHRMS.APP.App_UI.Forms.RC_Command" %>

<asp:Content ID="Content1" runat="server" contentplaceholderid="ContentPlaceHolder1">  
 
  <script type="text/javascript" src="../../Scripts/DatePicker.js"></script>
  <script type="text/javascript">
       function openProjectDetails(id, FromName) 
       {
           radopen("RC_CommandDtls.aspx?CmdSeq=" + id, "ProjectDtls"); 
       }
       function openReport() 
       {
           radopen("RPT_Exports.aspx?ReportName=RPT_CMD_Headers", "ProjectDtls");
       }
       function onTextChange(sender) 
       {
           if (sender.get_value() == "") {
               sender.set_text("");
           }
       }
       function MessageAlert(strMessageAlert) 
       {
           window.alert(strMessageAlert);
       }
   </script>
      
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" OnAjaxRequest="RadManager1_AjaxRequest">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="RadAjaxManager1">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadAjaxManager1" LoadingPanelID="RadAjaxLoadingPanel2" />
                    <telerik:AjaxUpdatedControl ControlID="CrystalReportViewer1" LoadingPanelID="RadAjaxLoadingPanel2" /> 
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="RadGrid2">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadGrid2" LoadingPanelID="RadAjaxLoadingPanel2" />
                    <telerik:AjaxUpdatedControl ControlID="CrystalReportViewer1" LoadingPanelID="RadAjaxLoadingPanel2" /> 
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
        
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="cmbEmployeeType">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadGrid2" LoadingPanelID="RadAjaxLoadingPanel2" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="cmbCommandType">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadGrid2" LoadingPanelID="RadAjaxLoadingPanel2" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>

    <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel2" runat="server">
    </telerik:RadAjaxLoadingPanel>
    
    
<telerik:RadWindowManager ID="RadWindowManager1" runat="server">
<Windows>
    <telerik:RadWindow 
        id="ProjectDtls" 
        runat="server"
        showcontentduringload="false"
        VisibleStatusbar="false"
        title="บัญชีรายละเอียดแนบท้ายคำสั่ง"
        width="1000px"
        Height="530px"        
        Modal="true"
        Skin = "Vista"
        behaviors="Close">
    </telerik:RadWindow>
</Windows>

</telerik:RadWindowManager>
    
    <title></title>
    <link href="../../Styles/CssClass.css" rel="stylesheet" type="text/css" /> 
    
    <asp:panel ID="Panel6" runat="server" >
    <table width="1000" cellpadding="0" cellspacing="0">
    <tr>        
        <td>
            
    <div class="moduleDivSlim1000">
    <div class="moduleDivBottom1000">
     <asp:Panel ID="PanelFilter" runat="server" Width="980px" ScrollBars="Auto">
        <table align = "center" width = "950px">
        <tr>
            <td align="left" >
                ประเภทบุคลากร :
                <telerik:RadComboBox ID="cmbEmployeeType" runat="server" 
                    AllowCustomText="true" 
                    AutoPostBack = "true"
                    CausesValidation="false" 
                    DataTextField="Name" 
                    DataValueField="Sequence" 
                    EmptyMessage="... เลือกประเภทบุคลากร ..." Filter="Contains" 
                    OnClientTextChange="onTextChange" Width="200px"                                        
                    onselectedindexchanged="cmbEmployeeType_SelectedIndexChanged">
                </telerik:RadComboBox>
                <asp:RequiredFieldValidator ID="v7" runat="server" 
                    ControlToValidate="cmbEmployeeType" ErrorMessage="*">
                </asp:RequiredFieldValidator>
            </td>
            <td align="left" >
                ประเภทคำสัง :
                <telerik:RadComboBox ID="cmbCommandType" runat="server" 
                    AllowCustomText="true" 
                    AutoPostBack = "true"
                    CausesValidation="false" 
                    DataTextField="cmd_type_descr" 
                    DataValueField="cmd_type_seq" 
                    EmptyMessage="...เลือกประเภทคำสัง ..." 
                    Filter="Contains" 
                    OnClientTextChange="onTextChange" 
                    Width="400px" 
                    onselectedindexchanged="cmbCommandType_SelectedIndexChanged" >
                </telerik:RadComboBox>
            </td>
            <td align="left" >
            </td>
        </tr>
    </table>
    </asp:Panel>
</div>
</div>

    </td>
    
  </tr>
  </table>
          

      <td>

      </td>
      
      <tr>
      <td colspan = "2">
    <div class="moduleDivSlim1000x450">
    <div class="moduleDivBottom1000">

        <table align="center" width ="980px" >
        <tr>
            <td align="left" class="tableHeader">
                ข้อมูลคำสั่ง</td>
        </tr>
        </table>
        <table width ="980px" align = "center" >
        <tr>
        <td >
            <asp:Panel ID="PanelGrid" runat="server" width ="970px" Height="350px" ScrollBars="Auto" >
                <telerik:RadGrid ID="RadGrid2" runat="server" 
                    AllowFilteringByColumn="True" 
                    AllowAutomaticDeletes="True" 
                    AllowMultiRowEdit="True" 
                    AllowMultiRowSelection="True" AllowPaging="True" 
                    AllowSorting="True" 
                    AutoGenerateColumns="False" EnableAJAX="True" 
                    EnableAJAXLoadingTemplate="True" GridLines="None" 
                    OnItemCommand="RadGrid2_ItemCommand" 
                    Skin="Outlook" width ="950px"
                    GroupingSettings-GroupByFieldsSeparator = "&nbsp;&nbsp;&nbsp;&nbsp;"
                    GroupingSettings-GroupContinuedFormatString = ""
                    GroupingSettings-GroupContinuesFormatString = ""
                    GroupingSettings-GroupSplitFormat = ""
                    onitemdatabound="RadGrid2_ItemDataBound">
                    <MasterTableView 
                        AllowMultiColumnSorting="True" 
                        CellSpacing="-1" 
                        ClientDataKeyNames="cmd_seq" 
                        CommandItemDisplay="Top" DataKeyNames="cmd_seq" 
                        InsertItemPageIndexAction="ShowItemOnCurrentPage" 
                        NoMasterRecordsText="&lt; ไม่มีข้อมูล &gt;">
                        <CommandItemTemplate>
                            <table width="100%">
                                <tr>
                                    <td>
                                        <asp:LinkButton ID="cmdAddNew" runat="server" CausesValidation="False" 
                                            CommandName="InitInsert" 
                                            Visible="<%# !RadGrid2.MasterTableView.IsItemInserted && RadGrid2.EditIndexes.Count <= 0 %>"> <img alt="" src="../Images/Buttons/AddRecord.gif" 
                                            style="border: 0px; vertical-align: middle;" /> จัดทำร่างคำสั่ง</asp:LinkButton>
                                        &nbsp;&nbsp;
                                    </td>
                                    <td align="right">
                                    </td>
                                </tr>
                            </table>
                        </CommandItemTemplate>
                        <RowIndicatorColumn>
                            <HeaderStyle Width="20px" />
                        </RowIndicatorColumn>
  
                        <ExpandCollapseColumn Visible="True">
                        </ExpandCollapseColumn>

                                <GroupByExpressions>
                            <telerik:GridGroupByExpression>
                           
                           <GroupByFields >                                       
                              <telerik:GridGroupByField 
                            FieldName="cmd_type_seq" 
                            HeaderText="Type" />                                       
                           
                           </GroupByFields>                           
                        
                           <SelectFields>
                            <telerik:GridGroupByField 
                                FieldName="cmd_type_name" 
                                HeaderText=" " 
                                HeaderValueSeparator = " " />                                                       
                            </SelectFields>                               
                                      
                            </telerik:GridGroupByExpression>
                        </GroupByExpressions>                
  
                        <Columns>
                            <telerik:GridEditCommandColumn ButtonType="ImageButton" 
                                EditText="คลิกเพื่อแก้ไขข้อมูล">
                                 <HeaderStyle HorizontalAlign="Center" Width="5%" />
                                <ItemStyle HorizontalAlign="Center" Width="5%" />
                            </telerik:GridEditCommandColumn>                      
                       
                            <telerik:GridButtonColumn ButtonType="ImageButton" CommandName="Delete" 
                                ConfirmDialogType="RadWindow" ConfirmText="ลบข้อมูลที่เลือก?" 
                                Text="คลิกเพื่อลบข้อมูล" UniqueName="column1">
                                <HeaderStyle HorizontalAlign="Center" Width="5%" />
                                <ItemStyle HorizontalAlign="Center" Width="5%" />
                            </telerik:GridButtonColumn>
                            <telerik:GridBoundColumn 
                                AutoPostBackOnFilter="true" 
                                ShowFilterIcon="false" 
                                CurrentFilterFunction="Contains" 
                                DataField="cmd_draft_no" 
                                FilterControlWidth="100%" 
                                HeaderStyle-HorizontalAlign="Center" 
                                HeaderText="เลขที่ร่างคำสั่ง" 
                                UniqueName = "cmd_draft_no">
                                <HeaderStyle HorizontalAlign="Center" Width="80px" />                     
                            </telerik:GridBoundColumn> 
                            <telerik:GridBoundColumn 
                                AutoPostBackOnFilter="true" 
                                ShowFilterIcon="false" 
                                CurrentFilterFunction="Contains" 
                                DataField="cmd_ref_no" 
                                FilterControlWidth="100%" 
                                HeaderStyle-HorizontalAlign="Center" 
                                HeaderText="เลขที่คำสั่ง" 
                                UniqueName = "cmd_ref_no">
                                <HeaderStyle HorizontalAlign="Center" Width="50px" />                  
                            </telerik:GridBoundColumn>                                                  
                            <telerik:GridBoundColumn 
                                AutoPostBackOnFilter="true" 
                                DataFormatString = "{0:d MMMM yyyy}"
                                ShowFilterIcon="false" 
                                CurrentFilterFunction="Contains" 
                                DataField="approved_date" 
                                FilterControlWidth="100%" 
                                HeaderStyle-HorizontalAlign="Center" 
                                ItemStyle-HorizontalAlign = "Center"
                                HeaderText="คำสั่งลงวันที่" 
                                UniqueName = "approved_date">
                                <HeaderStyle HorizontalAlign="Center" Width="80px" />                  
                            </telerik:GridBoundColumn>                                                  
                            <telerik:GridBoundColumn 
                                 Display="false"
                                 Visible = "false"     
                                 DataField="cmd_status" 
                                 UniqueName = "cmd_status">
                            </telerik:GridBoundColumn> 
                            <telerik:GridTemplateColumn 
                                AutoPostBackOnFilter="true" 
                                ShowFilterIcon="false" 
                                CurrentFilterFunction="Contains" 
                                DataField="cmd_name" 
                                FilterControlWidth="100%" 
                                HeaderStyle-HorizontalAlign="Center" 
                                HeaderStyle-Width = "100px"
                                HeaderText="เรื่อง" >              
                                <ItemTemplate>   
                                    <asp:LinkButton ID="targetControl" runat="server"                                        
                                        Text='<%# Eval("cmd_name") %>' 
                                        OnClientClick='<%# string.Format("return openProjectDetails(\"{0}\",\"{1}\");", Eval("cmd_seq"),Eval("from_name")) %>'>
                                    </asp:LinkButton>           
                                </ItemTemplate>               
                            </telerik:GridTemplateColumn> 
                            <telerik:GridBoundColumn 
                                AutoPostBackOnFilter="true" 
                                ShowFilterIcon="false" 
                                CurrentFilterFunction="Contains" 
                                DataField="approved_text" 
                                FilterControlWidth="100%" 
                                HeaderStyle-HorizontalAlign="Center" 
                                HeaderText="อนุมัติโดย" 
                                UniqueName = "approved_text">
                                <HeaderStyle HorizontalAlign="Center" Width="150px" />                  
                            </telerik:GridBoundColumn>    
                            <telerik:GridTemplateColumn 
                                AllowFiltering = "false"
                                HeaderStyle-HorizontalAlign="Center" 
                                HeaderStyle-Width = "20px"
                                ItemStyle-HorizontalAlign = "Center"
                                HeaderText="Print Preview" >           
                                <ItemTemplate>              
                                    <asp:LinkButton ID="cmdPrint" runat="server" CommandName = "PrintPreview" >
                                        <img style="border:0px;vertical-align:middle;" alt="พิมพ์คำสั่ง" src="../Images/Buttons/Print1.gif" />
                                    </asp:LinkButton>
                                </ItemTemplate>               
                            </telerik:GridTemplateColumn>           
                        </Columns>                         
                        <EditFormSettings EditFormType="WebUserControl" UserControlName="../UserControls/RC_Commands.ascx">
                            <EditColumn UniqueName="EditCommandColumn1">
                            </EditColumn>
                        </EditFormSettings>
                        <PagerStyle Mode="NextPrevNumericAndAdvanced" />
                        </MasterTableView>
                        <ClientSettings AllowColumnHide="True" AllowColumnsReorder="True" 
                            EnableRowHoverStyle="True" ReorderColumnsOnClient="True">
                            <Selecting AllowRowSelect="True" EnableDragToSelectRows="true" />
                        </ClientSettings>
                    </telerik:RadGrid>
                </asp:Panel>
            </td>
        </tr>
    </table>
</div>
</div>
</td>
</tr>


</asp:panel>
</asp:Content>
